﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DevFx.Web.Controls.Common
{
    public partial class DDL : System.Web.UI.UserControl
    {
        private int _width = 0;
        /// <summary>
        /// 长度
        /// </summary>
        public int Width 
        {
            set
            {
                _width = value;
                this.ddllist.Width = value;
            }
        }
        /// <summary>
        /// Value
        /// </summary>
        public string Value
        {
            set { this.ddllist.Items.IndexOf(ddllist.Items.FindByValue(value)); }
            get { return this.ddllist.SelectedItem.Value; }
        }
        /// <summary>
        /// Test
        /// </summary>
        public string Text
        {
            get { return this.ddllist.SelectedItem.Text; }
        }
        public void DataBind(object Source,string TextField,string ValueFiled)
        {
            this.ddllist.DataTextField = TextField;
            this.ddllist.DataValueField = ValueFiled;
            this.ddllist.DataSource = Source;
            this.ddllist.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ddllist_DataBound(object sender, EventArgs e)
        {
            this.ddllist.Items.Insert(0, new ListItem("", ""));
        }

    }
}